{template 'header'}
<body>
<div class="x-body">
    <form class="layui-form">
        <div class="layui-form-item">
            <label for="vip_task_first_per" class="layui-form-label">
                <span class="x-red">*</span>普通会员一级分销率
            </label>
            <div class="layui-input-inline">
                <input type="text" id="vip_task_first_per" name="vip_task_first_per" required="" lay-verify="vip_task_first_per"
                       autocomplete="off" value="{$setting['vip_task_first_per']}" class="layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux">
                <span class="x-red">*</span>百分值
            </div>
        </div>
        <div class="layui-form-item">
            <label for="agent_task_first_per" class="layui-form-label">
                <span class="x-red">*</span>代理商一级分销率
            </label>
            <div class="layui-input-inline">
                <input type="text" id="agent_task_first_per" name="agent_task_first_per" required=""
                       lay-verify="agent_task_first_per"
                       autocomplete="off" value="{$setting['agent_task_first_per']}" class="layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux">
                <span class="x-red">*</span>百分值
            </div>
        </div>
        <div class="layui-form-item">
            <label for="agent_task_second_per" class="layui-form-label">
                <span class="x-red"></span>代理商二级分销率
            </label>
            <div class="layui-input-inline">
                <input type="text" id="agent_task_second_per" name="agent_task_second_per" required=""
                       lay-verify="agent_task_second_per"
                       autocomplete="off" value="{$setting['agent_task_second_per']}" class="layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux">
                <span class="x-red"></span>百分值
            </div>
        </div>
        <div class="layui-form-item">
            <label for="L_repass" class="layui-form-label">
            </label>
            <button class="layui-btn" lay-filter="save" lay-submit="">
                保存
            </button>
        </div>
    </form>
</div>
<script>
    layui.use(['form', 'layer'], function () {
        $ = layui.jquery;
        var form = layui.form
            , layer = layui.layer;

        //自定义验证规则
        form.verify({
            vip_task_first_per: function (value) {
                if (value < 0) {
                    return '普通VIP一级分销率不能小于0';
                }
            }, agent_task_first_per: function (value) {
                if (value < 0) {
                    return '代理商一级分销率不能小于0';
                }
            }, agent_task_second_per: function (value) {
                if (value < 0) {
                    return '代理商二级分销率不能小于0';
                }
            }
        });

        //监听提交
        form.on('submit(save)', function (data) {
            console.log(data);
            var form_data = data.field
            //发异步，把数据提交给php
            var url = '{php echo $this->createWebUrl("setting",array("op"=>"fenxiao"))}'
            $.post(url, form_data, function (ret) {
                console.log(ret)
                if (ret.code) {
                    layer.msg(ret.msg, {icon: 1},function () {
                        location.reload()
                    });
                } else {
                    layer.msg(ret.msg, {icon: 0});
                }
            }, 'json')
            return false;
        });


    });
</script>
<script>var _hmt = _hmt || [];
(function () {
    var hm = document.createElement("script");
    hm.src = "https://hm.baidu.com/hm.js?b393d153aeb26b46e9431fabaf0f6190";
    var s = document.getElementsByTagName("script")[0];
    s.parentNode.insertBefore(hm, s);
})();</script>
</body>

</html>